package zero.tech.games.gate.hot;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import zero.tech.games.common.TopicOrder;
import zero.tech.redis.topic.TopicChannelType;
import zero.tech.redis.topic.service.api.IRedisMsgService;
import zero.tech.wsnet.data.Message;

@Component
public class NotifyUtil {
	@Autowired
	private IRedisMsgService redisMsgService;
	public void notifyData(Message msg, int... uidarr) {
		if(uidarr.length>0) {
			List<Integer> uids=new ArrayList<>();
			for(int uid:uidarr) {
				uids.add(uid);
			}
			NotifyData notifyData = new NotifyData();
			notifyData.getUids().addAll(uids);
			notifyData.setMsg(msg);
			redisMsgService.pulishRedisTopic(TopicChannelType.NOTIFY_DATA, TopicOrder.NOTIFY_DATA, notifyData);
		}
	}

	public static class NotifyData{
		private final List<Integer> uids=new ArrayList<>();
		private Message msg;
		public Message getMsg() {
			return msg;
		}
		public void setMsg(Message msg) {
			this.msg = msg;
		}
		public List<Integer> getUids() {
			return uids;
		}
	}
}
